package com.neuralnoise.facebook;

import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;

import com.restfb.DefaultFacebookClient;
import com.restfb.FacebookClient;

public class FacebookProperties {

	private static final String DEFAULT_PROPERTIES_FILENAME = "facebook.properties";

	private String apiKey;
	private String appSecret;
	private String accessToken;
	
	private String startUser;
	private long millis;
	
	private FacebookClient facebookClient;
	
	public FacebookProperties(String fileName) throws ConfigurationException {
		Configuration config = new PropertiesConfiguration(fileName);
		this.apiKey = config.getString("facebook.apiKey");
		this.appSecret = config.getString("facebook.appSecret");
		this.accessToken = config.getString("facebook.accessToken");
		
		if (config.containsKey("facebook.startUser"))
			this.startUser = config.getString("facebook.startUser"); // me, 1101281281, ..
		else
			this.startUser = "me";
		this.millis = config.getLong("facebook.millis");
		
		this.facebookClient = new DefaultFacebookClient(this.accessToken);
	}
}
